#!/usr/bin/env python
# -*- coding: UTF-8 -*-

try:
	import os
	import pygame
	import sys
	from pygame.font import Font, SysFont
except ImportError, err:
	print "Could not load %s module." % (err)
	sys.exit(2)


def load_image(name):
	fullname = os.path.join(name)
	try:
		surface = pygame.image.load(fullname)
	except pygame.error, message:
		print 'Cannot load image:', name
		raise SystemExit, message
	return surface.convert()


MenuBackgroundColor = (0, 0, 128)
WHITE = (255, 255, 255)
BLACK = (0,0,0)

FLD_TILE_SZ = 48

ERWIN_3 = 'img0189a'
WINDOW = 'IMG0001B'
CURSOR_ICONS = 'BC2b'

surfaces = {}
fonts = {}

def get_creature_surface(creature):
	if not creature in surfaces or surfaces[creature] is None:
		surfaces[creature] = load_image('./data/spr/' + creature + '.pcx')
	return surfaces[creature]

def get_window_surface():
	if not WINDOW in surfaces or surfaces[WINDOW] is None:
		surfaces[WINDOW] = load_image('./data/spr/' + WINDOW + '.pcx')
	return surfaces[WINDOW]

def get_window_font():
	if not 'window' in fonts or fonts['window'] is None:
		fonts['window'] = Font("./data/fonts/eurofurence_medium.ttf", 20)
		#fonts['window'] = SysFont("verasansyuanti", 16)
	return fonts['window']

def get_cursor_icons():
	if not CURSOR_ICONS in surfaces or surfaces[CURSOR_ICONS] is None:
		surfaces[CURSOR_ICONS] = load_image('./data/rescs/' + CURSOR_ICONS + '.pcx')
	return surfaces[CURSOR_ICONS]

